package com.yiren.backstage.currency.entity.record;

import android.util.Log;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;
import org.greenrobot.greendao.annotation.ToMany;

import java.util.List;

import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;

import com.yiren.backstage.db.dao.DaoSession;
import com.yiren.backstage.db.dao.ProjectGradeEntityDao;
import com.yiren.backstage.db.dao.ProjectInfoEntityDao;

/**
 * Describe 项目信息实体类
 *
 * @author WRX
 * @date 2022/7/25
 */
@Entity
public class ProjectInfoEntity {

    @Id(autoincrement = true)
    private Long id;

    /*** 外键 */
    private Long recordId;

    /*** 当前执行第几个项目 */
//    private int index;

    /*** 线路id */
    private String lineId;

    /*** 项目名称 */
    private String name;

    /*** 项目持续时间 */
    private long time;

    /*** 项目评分 */
    @ToMany(referencedJoinProperty = "projectId")
    private List<ProjectGradeEntity> projectGrade;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1931631268)
    private transient ProjectInfoEntityDao myDao;

    @Generated(hash = 251595174)
    public ProjectInfoEntity(Long id, Long recordId, String lineId, String name,
            long time) {
        this.id = id;
        this.recordId = recordId;
        this.lineId = lineId;
        this.name = name;
        this.time = time;
    }

    @Generated(hash = 479712204)
    public ProjectInfoEntity() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getRecordId() {
        return this.recordId;
    }

    public void setRecordId(Long recordId) {
        this.recordId = recordId;
    }

    public String getLineId() {
        return this.lineId;
    }

    public void setLineId(String lineId) {
        this.lineId = lineId;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getTime() {
        return this.time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 2036823645)
    public List<ProjectGradeEntity> getProjectGrade() {
        if (projectGrade == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ProjectGradeEntityDao targetDao = daoSession.getProjectGradeEntityDao();
            List<ProjectGradeEntity> projectGradeNew = targetDao
                    ._queryProjectInfoEntity_ProjectGrade(id);
            synchronized (this) {
                if (projectGrade == null) {
                    projectGrade = projectGradeNew;
                }
            }
        }
        return projectGrade;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 2013722793)
    public synchronized void resetProjectGrade() {
        projectGrade = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1360761605)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getProjectInfoEntityDao() : null;
    }
}
